package nc.hw;

import java.util.*;

public class HJ19 {

    public static void main(String[] args) {
        Map<String, Integer> times = new HashMap<>();
        List<String> records = new ArrayList<>();
        List<Integer> count = new ArrayList<>();
        int recordIndex = -1;
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            String line = scanner.nextLine();
            if (line.trim().equals("")) {
                break;
            }
            recordIndex = recordError(line, times, records, count, recordIndex);
        }
        for (int i = Integer.max(0, records.size() - 8); i < records.size(); i++) {
            String record = records.get(i);
            int recordTimes = count.get(times.get(record));
            System.out.println(record + " " + recordTimes);
        }
    }

    private static int recordError(String line, Map<String, Integer> times, List<String> records, List<Integer> count, int recordIndex) {
        int i = line.lastIndexOf(" ");
        String fileName = line.substring(0, i);
        fileName = fileName.substring(fileName.lastIndexOf("\\") + 1);
        if (fileName.length() > 16) {
            fileName = fileName.substring(fileName.length() - 16);
        }
        String recordName = fileName + " " + line.substring(i + 1);
        if (times.containsKey(recordName)) {
            Integer index = times.get(recordName);
            count.set(index, count.get(index) + 1);
            return recordIndex;
        } else {
            recordIndex ++;
            times.put(recordName, recordIndex);
            records.add(recordName);
            count.add(1);
            return recordIndex;
        }
    }

}
